/*
 * Eugen Stoian <stoian.e@gmail.com> 2010
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "ConstantsTable.h"

/**
  *\fn ConstantsTable::ConstantsTable()
  *\brief
  *
  */
ConstantsTable::ConstantsTable() {
    _constantsHash["NAN"] = Real::nan();
    _constantsHash["INF"] = Real::positiveInfinity();
    _constantsHash["EPSILON"] = Real::epsilon();
    _constantsHash["PI"] = Real::pi();
    _constantsHash["E"] = Real::e();//EULER
    _constantsHash["GAMMA"] = Real::gamma();//EULER-MASCHERONI
    _constantsHash["PHI"] = Real::phi();//GOLDEN RATIO
    _constantsHash["LAMBDA"] = Real::lambda();//CONWAY
    _constantsHash["ALPHA"] = Real::alpha();//FEIGENBAUM
    _constantsHash["DELTA"] = Real::delta();//FEIGENBAUM
}
/**
  *\fn ConstantsTable& ConstantsTable::instance()
  *\brief
  *
  */
ConstantsTable& ConstantsTable::instance() {
    static ConstantsTable * constantsTable = new ConstantsTable();
    return *constantsTable;
}


/**
  *\fn void ConstantsTable::add(const QString& constantName, Real value)
  *\brief
  *
  */
void ConstantsTable::add(const QString& constantName, Real value) {
    instance()._constantsHash[constantName] = value;
}

/**
  *\fn MathUnaryFun ConstantsTable::constant(const QString& constantName)
  *\brief
  *
  */

Real ConstantsTable::find(const QString& constantName) {
    return instance()._constantsHash.value(constantName, Real::nan());
}
/**
  *\fn MathUnaryFun ConstantsTable::constant(const QString& constantName)
  *\brief
  *
  */

Real ConstantsTable::constant(const QString& constantName) {
    return instance()._constantsHash.value(constantName);
}


/**
  *\fn QStringList ConstantsTable::names()
  *\brief
  *
  */
QStringList ConstantsTable::names() {
    return instance()._constantsHash.keys();
}
